//  exec 译为执行程序
const childProcess = require('child_process')

for (let i=0;i<3;i++){
    var workerProcess = childProcess.exec('node common.js ' +i,(error,stdout,stderr) =>{
        if (error) {
            console.log(error.stack);
            console.log('Error code: '+error.code);
            console.log('Signal received: '+error.signal);
        }else{
            if(stdout){
                console.log('stdout: ' + stdout);
            }
            if(stderr){
                console.log('stderr: ' + stderr);
            }
        }
    })
    workerProcess.on('exit', function (code) {
        console.log('子进程已退出，退出码 '+code);
    });
}
